var app = getApp();
//封装wx.request
function request(url, postData, doSuccess, doFail, doComplete) {
  var postData = app.globalData.openid;
  wx.request({
    url: url,
    data: JSON.stringify(postData),
    method: 'POST',
    header: {
      "dataType": "json",
      "Content-Type": "application/json",
    },
    success: function(res) {
      if (typeof doSuccess == "function") {
        // wx.hideLoading();
        doSuccess(res);
      }
    },
    fail: function() {
      if (typeof doFail == "function") {
        doFail();
        wx.hideLoading();
        wx.showModal({
          title: '网络错误',
          content: '网络出错，请刷新重试',
          showCancel: false,
        })
      }
    },
    complete: function() {
      if (typeof doComplete == "function") {
        doComplete();
        wx.hideLoading();
      }
    }
  })
}
module.exports = {
  request: request
}